package com.afu.demo;

import java.util.Scanner;
import java.util.*;

/**
 *     某商店规定：三个空汽水瓶可以换一瓶汽水，允许向老板借空汽水瓶（但是必须要归还）。
 *     小张手上有n个空汽水瓶，她想知道自己最多可以喝到多少瓶汽水。
 *     数据范围：输入的正整数满足 1≤n≤100
 */

public class Demo2{
    public static int drinkNum = 0 ;


    public static void main(String[] args) {
        ArrayList<Integer> integers = new ArrayList<Integer>();
        ArrayList<Integer> results = new ArrayList<Integer>();


        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            if (a != 0) {
                integers.add(a);
            } else {
                break;
            }
        }

        for (int i = 0; i < integers.size(); i++) {
            Integer rusult = getNum(integers.get(i));
            results.add(rusult);
        }
        results.stream().forEach(System.out::println);
    }



    private static int getNum(int sumNum) {
        int firstDrinkNum;

        //一轮之后的情况
        //喝的水
        firstDrinkNum = sumNum / 3;
        //剩下空瓶
        int firstLeftNum = sumNum % 3;
        //总的空瓶
        int firstSumNum = firstDrinkNum + firstLeftNum;

        if (firstSumNum ==0){
            return firstDrinkNum;
        }
        if (firstSumNum ==1){
            return firstDrinkNum;
        }
        if (firstSumNum ==2){
            return firstDrinkNum + 1;
        }

        return firstDrinkNum + getNum(firstSumNum);

    }
}